From 786eceea0e7c263966133fdb473bfbad52538db5 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Thu, 26 Feb 2004 16:38:27 +0000 Subject: [PATCH] bitkeeper revision 1.753 (403e2103aB5fs34t3drynDYnNdeFiw) kernel.c, process.c: Fix bug in idle-task switching. --- xen/arch/i386/process.c | 80 +++++++++++++++++++++-------------------- xen/common/kernel.c | 5 --- 2 files changed, 42 insertions(+), 43 deletions(-) diff --git a/xen/arch/i386/process.c b/xen/arch/i386/process.c index 62725ea84d..9adfb5ff40 100644 --- a/xen/arch/i386/process.c +++ b/xen/arch/i386/process.c @@ -235,33 +235,49 @@ void switch_to(struct task_struct *prev_p, struct task_struct *next_p) __cli(); /* Switch guest general-register state. */ - memcpy(&prev_p->shared_info->execution_context, - stack_ec, - sizeof(*stack_ec)); - memcpy(stack_ec, - &next_p->shared_info->execution_context, - sizeof(*stack_ec)); - - /* - * This is sufficient! If the descriptor DPL differs from CS RPL - * then we'll #GP. If DS, ES, FS, GS are DPL 0 then they'll be - * cleared automatically. If SS RPL or DPL differs from CS RPL - * then we'll #GP. - */ - if ( (stack_ec->cs & 3) == 0 ) - stack_ec->cs = FLAT_RING1_CS; - if ( (stack_ec->ss & 3) == 0 ) - stack_ec->ss = FLAT_RING1_DS; - - unlazy_fpu(prev_p); - - /* Switch the fast-trap handler. */ - CLEAR_FAST_TRAP(&prev_p->thread); - SET_FAST_TRAP(&next_p->thread); + if ( !is_idle_task(prev_p) ) + { + memcpy(&prev_p->shared_info->execution_context, + stack_ec, + sizeof(*stack_ec)); + unlazy_fpu(prev_p); + CLEAR_FAST_TRAP(&prev_p->thread); + } - /* Switch the guest OS ring-1 stack. */ - tss->esp1 = next->esp1; - tss->ss1 = next->ss1; + if ( !is_idle_task(next_p) ) + { + memcpy(stack_ec, + &next_p->shared_info->execution_context, + sizeof(*stack_ec)); + + /* + * This is sufficient! If the descriptor DPL differs from CS RPL then + * we'll #GP. If DS, ES, FS, GS are DPL 0 then they'll be cleared + * automatically. If SS RPL or DPL differs from CS RPL then we'll #GP. + */ + if ( (stack_ec->cs & 3) == 0 ) + stack_ec->cs = FLAT_RING1_CS; + if ( (stack_ec->ss & 3) == 0 ) + stack_ec->ss = FLAT_RING1_DS; + + SET_FAST_TRAP(&next_p->thread); + + /* Switch the guest OS ring-1 stack. */ + tss->esp1 = next->esp1; + tss->ss1 = next->ss1; + + /* Maybe switch the debug registers. */ + if ( next->debugreg[7] ) + { + loaddebug(next, 0); + loaddebug(next, 1); + loaddebug(next, 2); + loaddebug(next, 3); + /* no 4 and 5 */ + loaddebug(next, 6); + loaddebug(next, 7); + } + } /* Switch page tables. */ write_cr3_counted(pagetable_val(next_p->mm.pagetable)); @@ -272,18 +288,6 @@ void switch_to(struct task_struct *prev_p, struct task_struct *next_p) __asm__ __volatile__ ("lgdt %0" : "=m" (*next_p->mm.gdt)); load_LDT(next_p); - /* Maybe switch the debug registers. */ - if ( next->debugreg[7] ) - { - loaddebug(next, 0); - loaddebug(next, 1); - loaddebug(next, 2); - loaddebug(next, 3); - /* no 4 and 5 */ - loaddebug(next, 6); - loaddebug(next, 7); - } - __sti(); } diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 3f1d0fd24c..9db60eca82 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -224,11 +224,6 @@ void cmain(unsigned long magic, multiboot_info_t *mbi) init_page_allocator(__pa(&_end), MAX_MONITOR_ADDRESS); - /* These things will get done by do_createdomain() for all other tasks. */ - current->shared_info = (void *)get_free_page(GFP_KERNEL); - memset(current->shared_info, 0, sizeof(shared_info_t)); - set_fs(USER_DS); - /* Initialise the slab allocator. */ kmem_cache_init(); kmem_cache_sizes_init(max_page); -- 2.30.2